import many_to_one from "./components/manyToOneSchemas";
import one_to_one from "./components/oneToOneSchemas";
import many_to_many from "./components/manyToManySchemas";
import path from "path";

const apiPath = path.resolve(__dirname, "../routes/**/*.js");
const swaggerOptions: any = {
  definition: {
    openapi: "3.0.0",
    info: {
      title: "Express API with Swagger and TypeScript",
      version: "1.0.0",
      description: "API documentation for Express application",
    },
    servers: [
      {
        url:
          process.env.NODE_ENV === "production"
            ? process.env.SWAGGER_HOST || "http://localhost:3000"
            : "http://localhost:3000", // 修改为你的服务地址
        description: "Development server",
      },
    ],
    components: {
      schemas: {
        ...many_to_one,
        ...one_to_one,
        ...many_to_many,
      },
    },
  },
  apis: [apiPath], // 指定包含 Swagger 注解的文件路径
};

export default swaggerOptions;
